clear;
cla;
train_data = rand(5000,3);
test_data = rand(5000,3);

train_data = [train_data(:,1),train_data(:,2),(train_data(:,1)+train_data(:,2)).^2>2*train_data(:,3)];

train_data_y = train_data(:,3)==1;
train_data_n = train_data(:,3)==0;

scatter(train_data(train_data_y,1),train_data(train_data_y,2),'k');
hold on;
scatter(train_data(train_data_n,1),train_data(train_data_n,2),'g');

[ out,w ] = linear_classifier(train_data(:,[1,2]),train_data(:,3));

x = linspace(0,1);
y = ((-w(1) * x) - w(3))/w(2);
plot(x(y>0 & y<1),y(y>0 & y<1));

printf("%f\n",size(out((out>0.5) == train_data_y),1)/size(out,1));
printf("%f\n",size(out(((train_data(:,1)+train_data(:,2))>1) == train_data_y),1)/size(out,1));
